package com.huan.project;

//测试发送http请求

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class TestGetMessage {
    public static void main(String[] args) throws IOException {
        HttpURLConnection connection = null;
        URL url = new URL("https://v1.hitokoto.cn/");
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");

        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String input;
        StringBuilder content = new StringBuilder();
        while ((input=in.readLine())!=null){
            content.append(input);
        }
        in.close();
        connection.disconnect();
        System.out.println(content.toString());

    }
}
